package top.idcard.agent.biz.rw.write;

import top.idcard.agent.biz.rw.channel.RWContext;

/**
 * @author wx
 * @version 1.0
 * @date 2021/1/31 3:14 下午
 */
public abstract class AbstractWrite<T> implements Write<byte[]> {

    private RWContext channel;

    public AbstractWrite() {
        init();
        channel = RWContext.getInstance(this);
    }

    protected abstract void init();

    public abstract byte[] translateBytes(T t);

    public void writeObject(T data){
        write(translateBytes(data));
    }

    public abstract void write(byte[] data);

    public abstract void close();

    public abstract String dataFrom();
}
